<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page language="java" import="java.util.*,data.UserInfo" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Profile</title>
<link href="styles.css" rel="stylesheet" type="text/css" />

</head>
<body>
<script src="javascript/jquery.min.js">
$(document).ready(function(){
	$('a').click(function(event){
		event.preventDefault;
	});
});
</script>
<script type="text/javascript">
	
	function getCheckedValue(radioObj) {
		if(!radioObj)
			return "";
		var radioLength = radioObj.length;
		if(radioLength == undefined)
			if(radioObj.checked)
				return radioObj.value;
			else
				return "";
		var count = 0;
		for(var i = 0; i < radioLength; i++) {
			if(radioObj[i].checked) {
				return radioObj[i].value;
			}
		}
		return "";
	}
	function popup(url) 
	{
	 var width  = 500;
	 var height = 400;
	 var left   = (screen.width  - width)/2;
	 var top    = (screen.height - height)/2;
	 var params = 'width='+width+', height='+height;
	 params += ', top='+top+', left='+left;
	 params += ', directories=no';
	 params += ', location=no';
	 params += ', menubar=no';
	 params += ', resizable=no';
	 params += ', scrollbars=no';
	 params += ', status=no';
	 params += ', toolbar=no';
	 newwin=window.open(url,'windowname5', params);
	 if (window.focus) {newwin.focus();}
	 return false;
	}
	function select_item(i)
	{
		var anchor = document.getElementsByName("profname");
		var text = anchor[i].text;
		//anchor[i].href += "?text=" + text;
		popup("updateProfile.jsp"+"?text="+text);
	}
	
	function delete_item(){
		var item = getCheckedValue(document.forms[0].elements['profile']);
		$.post("profile_Drop", {hehe:item}, function(data){
            if(data.indexOf("<HTML>") == -1){
            	alert(data);
			}
            window.location.href = "profileList.jsp";
        });
        
		
	}
</script>
<jsp:useBean id="user" class="data.UserInfo" scope="session"/>
<div id="header">
    	<div class="mainLogo">
            <div class="logo style7">Information System Security </div>
            <div class="author">
              <p class="style8">&nbsp;</p>
              <p class="style8">AUTHOR : GROUP 1</p>
            </div>
        </div>
        <div class="icons">
        	<a href=""></a>&nbsp;<a href=""></a>        </div>
        <div id="navcontainer">
            <ul id="navlist">
                <li><a href="UserInfo.jsp">HOME</a></li>
                <li class="menuSeparator"><img src="images/menuSeparator.png" alt="" /></li>
                <li id="active"><a href="profileList.jsp">PROFILE </a></li>
                <li class="menuSeparator"><img src="images/menuSeparator.png" alt="" /></li>
                <li><a href="Role.jsp">ROLE</a></li>
                <li class="menuSeparator"><img src="images/menuSeparator.png" alt="" /></li>
                <li><a href="Table.jsp">TABLE</a></li>
                <li class="menuSeparator"><img src="images/menuSeparator.png" alt="" /></li>
                <li><a href="Contact.html">CONTACT</a></li>
            </ul>
        </div>
    
<div id="Header">
  <div id="HelloUser">
      <div align="right">
          Hello <jsp:getProperty name="user" property="username"/>!
          <br>
          <a href="index.jsp">Sign out</a>      </div>
  </div>
</div>
 
</div>

<br/><br/>

<div id="tabsG">
                                <ul>
                                        <!-- CSS Tabs -->
<li><a href="createProfile.jsp"><span>Create profile</span></a></li>
<li><a href="updateProfile.jsp"><span>Modify/Drop</span></a></li>

                                </ul>
  </div>
                <br /><br /><br /><br />

<div id="Layer1">
  <div align="center" class="style16">
    <p>PROFILE </p>
    <p class="style17">Choose one 1 these following profiles to modify/drop profile </p>
  </div>
</div>
<div id="Layer2">
	<form action="UserInfo.jsp" name = "profForm">	
  <table width="283" height="108" border="0" align="center" cellpadding="1" cellspacing="1"  bgcolor="#000000" >
    <%
   	ArrayList<String> list = (ArrayList<String>) session.getAttribute("profileList");
   	for(int i = 0; i < list.size(); i++){
   		String name = list.get(i);
%>
    <tr bgcolor="#121313">
      <td width="26"><input name="profile" type="radio" value = "<%=name%>">      </td>
      <td width="167"><a href = "" name = "profname" class="style18"  onclick = "select_item(<%=i%>)"><%=name%></a> </td>
    </tr>
    <%
    	}
   %>
    <tr bgcolor="#121313">
      <td><input name = "delete" type= "button" value = "Delete" 
   	onclick = "delete_item()"/>      </td>
      <td></td>
    </tr>
    <tr bgcolor="#121313">
      <th colspan = 2><div align="center">
        <input name="submit" type = "submit" value = "OK" />
        
      </div></th>
    </tr>
  </table>
  </form>
</div>
</body>
</html>